# 1.单线程
# 2.多线程
# 【3.资源共享与竞争】

import time
from threading import Thread, Lock

l = Lock()
a = 10
def funa():
    print('开始读取')
    l.acquire()
    print('A锁')
    global a
    time.sleep(5)
    print(f'读取结果a-->{a}')
    print('A解锁')
    l.release()
def funb():
    print('开始修改')
    l.acquire()
    print('B锁')
    global a
    a *= 10
    l.release()
    print('B解锁')
    print('修改结束')

if __name__ == '__main__' :
    ta = Thread(target=funa)
    ta.start()
    tb = Thread(target=funb)
    tb.start()
    tb.join()
    print('加锁的效果')













